﻿<template>
    <Modal v-model="isShow" class="modalwarp"  :width="560" title="审核" @on-cancel="Modal_cencel">
        <div class="model-wraper black_theme" > <!-- @keydown.enter.prevent="Modal_ok" -->
            <Form ref="formValidate" :model="formInfo" :label-width="100">
                <FormItem label="订单号：">{{res.orderId}}</FormItem>
                <FormItem label="申请时间：">{{res.applyRefundTime}}</FormItem>
                <FormItem label="售后事项：">{{res.refundItemName}}</FormItem>
                <FormItem label="商家确认：" required prop="reviewStatus">
                    <RadioGroup v-model="formInfo.reviewStatus">
                        <Radio :label="2" class="black_theme" size="large">审核通过</Radio>
                        <Radio :label="3" class="black_theme" size="large">审核不通过</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="说明原因：" :required="formInfo.reviewStatus==3" prop="remark" :show-message="false">
                    <Input 
                        type="textarea" show-word-limit
                        :autosize="{minRows: 4,maxRows: 8}" 
                        v-model="formInfo.remark" 
                        class="fromInput"
                    ></Input>
                </FormItem>
            </Form>
        </div>
        <div slot="footer">
            <Button size="large" @click="Modal_cencel">取消</Button>
            <Button :loading="save_loading" type="primary" size="large" @click="Modal_ok">确定</Button>
        </div>
    </Modal>
</template>
<script>
    export default {
        name: 'AuditPopup',
        props: ['value','id','res'],
        data() {
            return {
                save_loading: false,
                formInfo: {
                    reviewStatus: 2,
                    remark: '',
                },
            }
        },
        created() {

        },
        computed: {
            isShow: {
                get(){
                    return this.value
                },
                set(newVal){
                    this.$emit("input", newVal); 
                }
            }
        },
        methods: {
            Modal_cencel(){
                this.isShow = false;
                this.$nextTick(this.$refs['formValidate'].resetFields);
            },
            Modal_ok() {
                this.$refs['formValidate'].validate(async (valid) => {
                    if (valid) {
                        this.save_loading = true
                        let requedata = this.$cloneObj(this.formInfo);
                        requedata.sellerConfirmId = this.id;
                        let res = await this.$post('orderReviewByPlat',requedata);
                        this.save_loading = false
                        if(res) {
                            this.$tipsMessage('审核成功',1);
                            this.Modal_cencel();
                            this.$emit('ok');
                        }
                    } else {
                        this.$tipsMessage('提交失败');
                    }
                });
                
            },
        },
        watch: {
        }
    };
</script>
<style scoped lang="less">
    /deep/ .ivu-form-item{
        margin-bottom: 15px;
    }
</style>